package com.danbay.cloud.account.service.api;

import com.danbay.cloud.account.dto.EmployeeDto;
import com.danbay.cloud.account.dto.EmployeeInfoDto;
import com.danbay.framework.db.pagination.PageParam;
import com.danbay.framework.db.pagination.PageResult;
import com.danbay.framework.exception.BusinessException;
import com.danbay.framework.springnc.annotation.AutoController;
import com.danbay.framework.springnc.annotation.RequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author SJG
 *         2018/1/4.
 */
@AutoController
@RequestMapping("/account-service/employee")
@Api("员工信息操作接口")
public interface IEmployeeService {

    /**
     * 分页查询企业下员工信息
     *
     * @param param 查询参数
     * @return 员工列表
     */
    @ApiOperation(value = "分页查询企业下员工信息")
    @RequestMapping(value = "/findByPage", method = RequestMethod.POST)
    PageResult<EmployeeInfoDto> findByPage(@RequestBody PageParam<EmployeeInfoDto> param);

    /**
     * 取员工信息
     *
     * @param eid 员工id
     * @return 员工信息
     * @throws BusinessException 业务异常
     */
    @ApiOperation(value = "取员工信息")
    @RequestMapping(value = "/get", method = RequestMethod.GET)
    EmployeeInfoDto get(@ApiParam("员工id") Integer eid) throws BusinessException;

    /**
     * 添加员工信息
     * 添加员工后会生成员工账户，再设置员工账户的权限
     *
     * @param employee 员工信息
     * @throws BusinessException 业务异常
     */
    @ApiOperation(value = "添加员工", notes = "添加员工后会生成员工账户，再设置员工账户的权限")
    @RequestMapping(value = "/add", method = RequestMethod.POST)
    void add( @RequestBody EmployeeDto employee) throws BusinessException;

    /**
     *
     * 检查员工电话号码是否存在
     * @param eid 员工所在企业id
     * @param phoneNum 员工电话号码
     * @throws BusinessException 业务异常
     */
    @ApiOperation(value = "检查员工电话号码是否存在", notes = "添加员工前检查")
    @RequestMapping(value = "/checkPhoneNumExists", method = RequestMethod.GET)
    void checkPhoneNumExists(@ApiParam("员工所在企业id") @RequestParam("eid") Integer eid,
                             @ApiParam("员工电话号码") @RequestParam("phoneNum") String phoneNum) throws BusinessException;


    /**
     * 员工账户注册成功后,发送注册短信
     * @param mobile 员工账户电话
     * @param name 企业名
     */
    @ApiOperation(value = "员工账户注册成功后,发送注册短信")
    @RequestMapping(value = "/sendRegMessage", method = RequestMethod.POST)
    void sendRegMessage(@ApiParam("员工账户电话") @RequestParam("mobile") String mobile, @ApiParam("企业名") @RequestParam("name") String name) throws BusinessException;

    /**
     * 冻结员工
     * 登录时要判断账户所在账户组的企业中的员工是否已冻结，冻结的员工不能登录
     *
     * @param eid 员工id
     * @throws BusinessException 业务异常
     */
    @ApiOperation(value = "冻结员工", notes = "登录时要判断账户所在账户组的企业中的员工是否已冻结")
    @RequestMapping(value = "/freeze", method = RequestMethod.POST)
    void freeze(@ApiParam("员工id") Integer eid) throws BusinessException;

    /**
     * 解冻员工
     *
     * @param eid 员工id
     * @throws BusinessException 业务异常
     */
    @ApiOperation(value = "解冻员工")
    @RequestMapping(value = "/unfreeze", method = RequestMethod.POST)
    void unfreeze(@ApiParam("员工id") Integer eid) throws BusinessException;

    /**
     * 删除员工
     * 1.删除员工信息,2.取消员工账户所在企业组
     *
     * @param eid 员工id
     * @throws BusinessException 业务异常
     */
    @ApiOperation(value = "删除员工", notes = "1.删除员工信息,2.取消员工账户所在企业组")
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    void delete(@ApiParam("员工id") Integer eid) throws BusinessException;
}
